// diy/components/xcdiytitle.js
var behaviorsbasic = require('../../behavior/basic') 
Component({
  behaviors: [behaviorsbasic],
  /**
   * 组件的属性列表
   */
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  properties: {
    objmodel: {
      type: Object,
      default: ''
    }, 
  },

  /**
   * 组件的初始数据
   */
  data: {
    dotnums: 0,
    scrollleft: 0,
    syswidth: 375,
    scrollWidth: 0,
  },

  ready(){
   
    this.setData({
      scrollleft: 1,
      syswidth: wx.getSystemInfoSync().windowWidth
    })

   
  },
  /**
   * 组件的方法列表
   */
  methods: {
    initsiper(ev) {

      
      var scrollWidth = ev.detail.scrollWidth;
     

      var syswidth = this.data.syswidth


      var mod_val = scrollWidth % syswidth
  

      var dotnums = (scrollWidth - mod_val) / syswidth + (mod_val > 0 ? 1 : 0)

   
      
      this.setData({ scrollleft: 0, scrollWidth, dotnums })
    },
    changescrollleft(ev) {
      switch (ev.op) {
        case "setleft": {
          var scrollleft = this.data.syswidth * ev.idx
          if (this.data.scrollleft == scrollleft) {
            scrollleft--
          }
          this.setData({ scrollleft: scrollleft })
          break;
        }
      }
    }
  }
})
